import { request } from './request'
import qs from 'qs'

const defaultHandle = (api) => {
  return api
    .then((res) => {
     // console.log('res: ', res)
      if (
        res?.data?.code === 20000 ||
        res?.data?.code === 20001 ||
        res?.data?.code === 20002 ||
        res?.data?.code === 200002 ||
        res?.data?.code === 200001 ||
        res?.data?.code === 1
      ) {
        return Promise.resolve(res?.data?.data || res?.data)
      }
    })
    .catch((err) => {
      console.log('err: ', err)
    })
}
//首页爬虫任务列表
export const getPlant=(data)=>
  defaultHandle(request.get('/api/plant?'+qs.stringify(data)))

export const getGroup=(req) =>
  defaultHandle(request.get('/api/group?' + qs.stringify(req)))


